<div class="frame_configDiv">
	<style>
	textarea{width:400px;height:100px;margin:5px;}
	</style>
	<form name="configForm" id="configForm" action="administrator-system-attr" method="post">
	  <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#c8d9e9">
		<tr>
		  <td>CATEGORY</td>
		</tr>
		<tr>
			<td>
				<div><input type="button" value="添加" onclick="addCategory(this);" /></div>
				<?php if ($this->category):?>
					<?foreach($this->category as $value):?>
						<div class="navDiv">类目名：<input name="category_name[]" type="text" value="<?=$value->attr_name?>" />&nbsp;&nbsp;&nbsp;&nbsp;顺序：<input name="category_order[]" type="text" value="<?=$value->attr_order;?>" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="category_id[]" value="<?php echo $value->attr_id?>" /><br /><textarea name="category_desc[]"><?php echo $value->attr_desc;?></textarea><input type="button" value="删除" onclick="subCategory(this);" /></div>
					<?endforeach;?>
				<?php endif;?>
			</td>
		</tr>
		<tr>
		  <td>BRAND</td>
		</tr>
		<tr>
			<td>
				<div><input type="button" value="添加" onclick="addBrand(this);" /></div>
				<?php if ($this->brand):?>
					<?foreach($this->brand as $value):?>
						<div class="navDiv1">品牌名：<input name="brand_name[]" type="text" value="<?=$value->attr_name?>" />&nbsp;&nbsp;&nbsp;&nbsp;顺序：<input name="brand_order[]" type="text" value="<?=$value->attr_order?>" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="brand_id[]" value="<?php echo $value->attr_id?>" /><br /><textarea name="brand_desc[]"><?php echo $value->attr_desc;?></textarea><input type="button" value="删除" onclick="subBrand(this);" /></div>
					<?endforeach;?>
				<?php endif;?>
			</td>
		</tr>
		
		<tr>
		  <td>PLAYER</td>
		</tr>
		<tr>
			<td>
				<div><input type="button" value="添加" onclick="addPlayer(this);" /></div>
				<?php if ($this->player):?>
					<?foreach($this->player as $value):?>
						<div class="navDiv2">选手名：<input name="player_name[]" type="text" value="<?=$value->attr_name?>" />&nbsp;&nbsp;&nbsp;&nbsp;顺序：<input name="player_order[]" type="text" value="<?=$value->attr_order?>" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="player_id[]" value="<?php echo $value->attr_id?>" /><br /><textarea name="player_desc[]"><?php echo $value->attr_desc;?></textarea><input type="button" value="删除" onclick="subPlayer(this);" /></div>
					<?endforeach;?>
				<?php endif;?>
			</td>
		</tr>
		<tr>
		  <td><input type="submit" value="提交" /></td>
		</tr>
	  </table>
	</form>
</div>
<script>
function addCategory(thisButton){
	$(thisButton).parent().parent().append('<div class="navDiv">类目名：<input name="category_name[]" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;顺序：<input name="category_order[]" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="category_id[]" value="0" /><br /><textarea name="category_desc[]"></textarea><input type="button" value="删除" onclick="subCategory(this);" /></div>');
	commonEffection.resetFrame('admins_frame',true);
}
function addBrand(thisButton){
	$(thisButton).parent().parent().append('<div class="navDiv1">属性名：<input name="brand_name[]" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;顺序：<input name="brand_order[]" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="brand_id[]" value="0" /><br /><textarea name="brand_desc[]"></textarea><input type="button" value="删除" onclick="subBrand(this);" /></div>');
	commonEffection.resetFrame('admins_frame',true);
}
function addPlayer(thisButton){
	$(thisButton).parent().parent().append('<div class="navDiv2">选手名：<input name="player_name[]" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;顺序：<input name="player_order[]" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="player_id[]" value="0" /><br /><textarea name="player_desc[]"></textarea><input type="button" value="删除" onclick="subPlayer(this);" /></div>');
	commonEffection.resetFrame('admins_frame',true);
}
function subCategory(thisButton){
	if($('.navDiv').size()>1){
		id = $(thisButton).parent().find('input[name="category_id[]"]').val();
		if (id > 0) {
			del(id, thisButton);
		} else {
			$(thisButton).parent().remove();
			commonEffection.resetFrame('admins_frame',true);
		}
	}
}
function subBrand(thisButton){
	if($('.navDiv1').size()>1){
		id = $(thisButton).parent().find('input[name="brand_id[]"]').val();
		if (id > 0) {
			del(id, thisButton);
		} else {
			$(thisButton).parent().remove();
			commonEffection.resetFrame('admins_frame',true);
		}
	}
}
function subPlayer(thisButton){
	if($('.navDiv2').size()>1){
		id = $(thisButton).parent().find('input[name="player_id[]"]').val();
		if (id > 0) {
			del(id, thisButton);
		} else {
			$(thisButton).parent().remove();
			commonEffection.resetFrame('admins_frame',true);
		}
	}
}
function del(id, obj)
{
	$.ajax({
		type: "POST",
		url: "/administrator-system-delattr",
		data: {id: id},
		success: function(data) {			
			switch(data) {					
				case "0":					
					$(obj).parent().remove();
					commonEffection.resetFrame('admins_frame',true);
					break;
				case "1":
					alert('该属性有产品不能删除') ;
					break;			
				default:
					alert(data);
			}
		}	
	}
	);	
}
</script>